home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Now 11 / CD-ROM Now MegaDisc 11 (1995-02).iso / discs / internet / unix5.txt < prev    next >
Internet Message Format  |  1994-10-26  |  12KB

  1. Path: bloom-beacon.mit.edu!senator-bedfellow.mit.edu!faqserv
  2. From: tmatimar@isgtec.com (Ted Timar)
  3. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  4. Subject: Unix - Frequently Asked Questions (5/7) [Frequent posting]
  5. Supersedes: <unix-faq/faq/part5_779635319@rtfm.mit.edu>
  6. Followup-To: comp.unix.questions
  7. Date: 23 Sep 1994 19:34:38 GMT
  8. Organization: ISG Technologies, Inc
  9. Lines: 278
  10. Approved: news-answers-request@MIT.Edu
  11. Distribution: world
  12. Expires: 21 Oct 1994 19:25:02 GMT
  13. Message-ID: <unix-faq/faq/part5_780348302@rtfm.mit.edu>
  14. References: <unix-faq/faq/contents_780348302@rtfm.mit.edu>
  15. NNTP-Posting-Host: bloom-picayune.mit.edu
  16. X-Last-Updated: 1994/09/08
  17. Originator: faqserv@bloom-picayune.MIT.EDU
  18. Xref: bloom-beacon.mit.edu comp.unix.questions:32520 comp.unix.shell:13051 comp.answers:7427 news.answers:26211
  19.  
  20. Archive-name: unix-faq/faq/part5
  21. Version: $Id: part5,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  22.  
  23. These seven articles contain the answers to some Frequently Asked
  24. Questions often seen in comp.unix.questions and comp.unix.shell.
  25. Please don't ask these questions again, they've been answered plenty
  26. of times already - and please don't flame someone just because they may
  27. not have read this particular posting.  Thank you.
  28.  
  29. This collection of documents is Copyright (c) 1994, Ted Timar, except
  30. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  31. All rights reserved.  Permission to distribute the collection is
  32. hereby granted providing that distribution is electronic, no money
  33. is involved, reasonable attempts are made to use the latest version
  34. and all credits and this copyright notice are maintained.
  35. Other requests for distribution will be considered.  All reasonable
  36. requests will be granted.
  37.  
  38. All information here has been contributed with good intentions, but
  39. none of it is guaranteed either by the contributors or myself to be
  40. accurate.  The users of this information take all responsibility for
  41. any damage that may occur.
  42.  
  43. Many FAQs, including this one, are available on the archive site
  44. rtfm.mit.edu in the directory pub/usenet/news.answers.
  45. The name under which a FAQ is archived appears in the "Archive-Name:"
  46. line at the top of the article.  This FAQ is archived as
  47. "unix-faq/faq/part[1-7]".
  48.  
  49. These articles are divided approximately as follows:
  50.  
  51.       1.*) General questions.
  52.       2.*) Relatively basic questions, likely to be asked by beginners.
  53.       3.*) Intermediate questions.
  54.       4.*) Advanced questions, likely to be asked by people who thought
  55.            they already knew all of the answers.
  56.       5.*) Questions pertaining to the various shells, and the differences.
  57.       6.*) An overview of Unix variants.
  58.       7.*) An comparison of configuration management systems (RCS, SCCS).
  59.  
  60. This article includes answers to:
  61.  
  62.       5.1)  Can shells be classified into categories?
  63.       5.2)  How do I "include" one shell script from within another
  64.             shell script?
  65.       5.3)  Do all shells have aliases?  Is there something else that
  66.             can be used?
  67.       5.4)  How are shell variables assigned?
  68.       5.5)  How can I tell if I am running an interactive shell?
  69.       5.6)  What "dot" files do the various shells use?
  70.       5.7)  I would like to know more about the differences between the
  71.             various shells.  Is this information available some place?
  72.  
  73. If you're looking for the answer to, say, question 5.5, and want to skip
  74. everything else, you can search ahead for the regular expression "^5.5)".
  75.  
  76. While these are all legitimate questions, they seem to crop up in
  77. comp.unix.questions or comp.unix.shell on an annual basis, usually
  78. followed by plenty of replies (only some of which are correct) and then
  79. a period of griping about how the same questions keep coming up.  You
  80. may also like to read the monthly article "Answers to Frequently Asked
  81. Questions" in the newsgroup "news.announce.newusers", which will tell
  82. you what "UNIX" stands for.
  83.  
  84. With the variety of Unix systems in the world, it's hard to guarantee
  85. that these answers will work everywhere.  Read your local manual pages
  86. before trying anything suggested here.  If you have suggestions or
  87. corrections for any of these answers, please send them to to
  88. tmatimar@isgtec.com.
  89.  
  90. ----------------------------------------------------------------------
  91.  
  92. Subject: Can shells be classified into categories?
  93. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  94. Date: Wed, 7 Oct 92 14:28:18 -0500
  95.  
  96.  
  97. 5.1)  Can shells be classified into categories?
  98.  
  99.       In general there are two main class of shells.  The first class
  100.       are those shells derived from the Bourne shell which includes sh,
  101.       ksh, bash, and zsh.  The second class are those shells derived
  102.       from C shell and include csh and tcsh.  In addition there is rc
  103.       which most people consider to be in a "class by itself" although
  104.       some people might argue that rc belongs in the Bourne shell class.
  105.  
  106.       With the classification above, using care, it is possible to
  107.       write scripts that will work for all the shells from the Bourne
  108.       shell category, and write other scripts that will work for all of
  109.       the shells from the C shell category.
  110.  
  111. ------------------------------
  112.  
  113. Subject: How do I "include" one shell script from within another shell script?
  114. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  115. Date: Wed, 7 Oct 92 14:28:18 -0500
  116.  
  117. 5.2)  How do I "include" one shell script from within another shell script?
  118.  
  119.       All of the shells from the Bourne shell category (including rc)
  120.       use the "." command.  All of the shells from the C shell category
  121.       use "source".
  122.  
  123. ------------------------------
  124.  
  125. Subject: Do all shells have aliases?  Is there something else that can be used?
  126. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  127. Date: Wed, 7 Oct 92 14:28:18 -0500
  128.  
  129. 5.3)  Do all shells have aliases?  Is there something else that can be used?
  130.  
  131.       All of the major shells other than sh have aliases, but they
  132.       don't all work the same way.  For example, some don't accept
  133.       arguments.
  134.       
  135.       Although not strictly equivalent, shell functions (which exist in
  136.       most shells from the Bourne shell category) have almost the same
  137.       functionality of aliases.  Shell functions can do things that
  138.       aliases can't do.  Shell functions did not exist in bourne shells
  139.       derived from Version 7 Unix, which includes System III and BSD 4.2.
  140.       BSD 4.3 and System V shells do support shell functions.
  141.       
  142.       Use unalias to remove aliases and unset to remove functions.
  143.  
  144. ------------------------------
  145.  
  146. Subject: How are shell variables assigned?
  147. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  148. Date: Wed, 7 Oct 92 14:28:18 -0500
  149.  
  150. 5.4)  How are shell variables assigned?
  151.  
  152.       The shells from the C shell category use "set variable=value" for
  153.       variables local to the shell and "setenv variable value" for
  154.       environment variables.  To get rid of variables in these shells
  155.       use unset and unsetenv.  The shells from the Bourne shell
  156.       category use "variable=value" and may require an "export
  157.       VARIABLE_NAME" to place the variable into the environment.  To
  158.       get rid of the variables use unset.
  159.  
  160. ------------------------------
  161.  
  162. Subject: How can I tell if I am running an interactive shell?
  163. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  164. From: dws@ssec.wisc.edu (DaviD W. Sanderson)
  165. Date: Fri, 23 Oct 92 11:59:19 -0600
  166.  
  167. 5.5)  How can I tell if I am running an interactive shell?
  168.  
  169.       In the C shell category, look for the variable $prompt.
  170.  
  171.       In the Bourne shell category, you can look for the variable $PS1,
  172.       however, it is better to check the variable $-.  If $- contains
  173.       an 'i', the shell is interactive.  Test like so:
  174.  
  175.           case $- in
  176.           *i*)    # do things for interactive shell
  177.                   ;;
  178.           *)      # do things for non-interactive shell
  179.                   ;;
  180.           esac
  181.  
  182. ------------------------------
  183.  
  184. Subject: What "dot" files do the various shells use?
  185. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  186. From: tmb@idiap.ch (Thomas M. Breuel)
  187. Date: Wed, 28 Oct 92 03:30:36 +0100
  188.  
  189. 5.6)  What "dot" files do the various shells use?
  190.  
  191.       Although this may not be a complete listing, this provides the
  192.       majority of information.
  193.  
  194.       csh
  195.           Some versions have system-wide .cshrc and .login files.  Every
  196.           version puts them in different places.
  197.  
  198.           Start-up (in this order):
  199.               .cshrc   - always.
  200.               .login   - login shells.
  201.  
  202.           Upon termination:
  203.               .logout  - login shells.
  204.  
  205.           Others:
  206.               .history - saves the history (based on $savehist).
  207.  
  208.       tcsh
  209.           Start-up (in this order):
  210.               /etc/csh.cshrc - always.
  211.               /etc/csh.login - login shells.
  212.               .tcshrc        - always.
  213.               .cshrc         - if no .tcshrc was present.
  214.               .login         - login shells
  215.  
  216.           Upon termination:
  217.               .logout        - login shells.
  218.  
  219.           Others:
  220.               .history       - saves the history (based on $savehist).
  221.               .cshdirs       - saves the directory stack.
  222.  
  223.       sh
  224.           Start-up (in this order):
  225.               /etc/profile - login shells.
  226.               .profile     - login shells.
  227.  
  228.           Upon termination:
  229.               any command (or script) specified using the command:
  230.                  trap "command" 0
  231.  
  232.       ksh
  233.           Start-up (in this order):
  234.               /etc/profile - login shells.
  235.               .profile     - login shells.
  236.               $ENV         - always, if it is set.
  237.  
  238.           Upon termination:
  239.               any command (or script) specified using the command:
  240.                  trap "command" 0
  241.  
  242.       bash
  243.           Start-up (in this order):
  244.               /etc/profile  - login shells.
  245.               .bash_profile - login shells.
  246.               .profile      - login if no .bash_profile is present.
  247.               .bashrc       - interactive non-login shells.
  248.               $ENV          - always, if it is set.
  249.  
  250.           Upon termination:
  251.               .bash_logout  - login shells.
  252.  
  253.           Others:
  254.               .inputrc      - Readline initialization.
  255.  
  256.       zsh
  257.           Start-up (in this order):
  258.               .zshenv   - always, unless -f is specified.
  259.               .zprofile - login shells.
  260.               .zshrc    - interactive shells, unless -f is specified.
  261.               .zlogin   - login shells.
  262.  
  263.           Upon termination:
  264.               .zlogout  - login shells.
  265.  
  266.       rc
  267.           Start-up:
  268.               .rcrc - login shells
  269.  
  270. ------------------------------
  271.  
  272. Subject: I would like to know more about the differences ... ?
  273. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  274. Date: Wed, 7 Oct 92 14:28:18 -0500
  275.  
  276. 5.7)  I would like to know more about the differences between the
  277.       various shells.  Is this information available some place?
  278.  
  279.       A very detailed comparison of sh, csh, tcsh, ksh, bash, zsh, and
  280.       rc is available via anon.  ftp in several places:
  281.  
  282.       cs.uwp.edu (131.210.1.4):pub/vi/docs/shell-100.BetaA.Z
  283.       utsun.s.u-tokyo.ac.jp:misc/vi-archive/docs/shell-100.BetaA.Z
  284.  
  285.       This file compares the flags, the programming syntax,
  286.       input/output redirection, and parameters/shell environment
  287.       variables.  It doesn't discuss what dot files are used and the
  288.       inheritance for environment variables and functions.
  289.  
  290. ------------------------------
  291.  
  292. End of unix/faq Digest part 5 of 7
  293. **********************************
  294.  
  295. -- 
  296. Ted Timar - tmatimar@isgtec.com
  297. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  298.